package gui.user.model;

import dao.ProductCategoryDao;
import entity.ProductCategory;

import javax.swing.*;
import java.util.List;

public class CategoryListModel extends DefaultListModel {
    ProductCategoryDao productCategoryDao = new ProductCategoryDao();
    List categoryList = null;

    public CategoryListModel() throws Exception {
        //获取所有商品分类信息
        categoryList = productCategoryDao.getAllProductCategory();
        //将所有信息添加进JList
        for (int i = 0; i < categoryList.size(); i++) {
            //遍历所有分类信息
            ProductCategory productCategory = (ProductCategory)categoryList.get(i);
            //添加
            this.addElement(productCategory.getCategoryName());
        }
    }
}
